package com.itheima.service.impl;

import com.itheima.mapper.MemberDao;
import com.itheima.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Service
@Transactional
public class MemberServiceImpl implements MemberService {
    @Autowired
    private MemberDao memberDao;
    @Override
    public List<Object> findMemberCountByMonths(List<String> months) {
        return months.stream()
                .map( month -> memberDao.findMemberCountBeforeDate( month + ".31" ) )
                .collect( Collectors.toList() );
    }
    
}
